package com.zhuiyun.project.api.onlineservice.mapper;

import com.zhuiyun.project.api.onlineservice.entity.OnlineserviceChat;
import com.zhuiyun.project.common.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName OnlineserviceChatMapper
 * @Description TODO
 * @Author ZSH
 * @Date 2024/3/13 16.08
 **/
@Mapper
public interface OnlineserviceChatMapper extends BaseMapper<OnlineserviceChat> {
    @Insert("INSERT INTO onlineservice_chat (senderId, receiverId, setAvatarUrl, receiverName, message, type, time, username) " +
            "VALUES (#{senderId}, #{receiverId}, #{setAvatarUrl}, #{receiverName}, #{message}, #{type}, #{time}, #{username})")
    int addOnLine(OnlineserviceChat onChat);

    @Select("select * from onlineservice_chat where time <DATE_SUB(NOW(), INTERVAL 1 MONTH)")
    List<OnlineserviceChat> selectList();

    @Delete("delete from onlineservice_chat where id=#{id}")
    int del(Integer id);
}
